package net.huashitong.supervision.excel.service;

import com.alibaba.fastjson.JSONObject;
import com.sirdc.modules.core.dao.BaseDao;
import com.sirdc.modules.sys.base.StringPKService;
import com.sirdc.modules.sys.entity.SysDept;
import com.sirdc.modules.sys.entity.SysLogin;
import com.sirdc.modules.sys.entity.SysUser;
import com.sirdc.modules.sys.filter.SysDeptFilter;
import com.sirdc.modules.sys.filter.SysUserFilter;
import com.sirdc.modules.sys.service.*;
import com.sirdc.modules.sys.util.SysUserUtils;
import com.sirdc.modules.utils.ObjectUtils;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.supervision.excel.Entity.ExcelDataEntity;
import net.huashitong.supervision.excel.dao.ExcelDataDao;
import net.huashitong.supervision.gongjian.dto.FeedBackDTO;
import net.huashitong.supervision.gongjian.entity.ProjectFeedBackEntity;
import net.huashitong.supervision.gongjian.entity.project.*;
import net.huashitong.supervision.gongjian.filter.*;
import net.huashitong.supervision.gongjian.service.ProjectFeedBackService;
import net.huashitong.supervision.gongjian.service.project.*;
import net.huashitong.supervision.insideDuCha.filter.InsideSubTaskFilter;
import net.huashitong.supervision.task.filter.TaskSubFilter;
import net.huashitong.util.DateUtil;
import net.huashitong.util.UtilsTools;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import sun.font.TrueTypeFont;

import javax.naming.event.NamingListener;
import java.io.*;
import java.util.*;

@Service
public class ExcelDataService extends StringPKService<ExcelDataEntity> {

    @Autowired
    private ExcelDataDao dao;
    @Autowired
    private SysTableService sysTableService;
    @Autowired
    @Lazy(true)
    private DeptService deptService;
    @Autowired
    private RedisService redisService;
    @Autowired
    private SysUserService sysUserService;
    @Autowired
    private SysLoginService loginService;

    @Value("${wen.template}")
    private String excelPath;

    @Autowired
    private ZhengQianService zhengQianService;
    @Autowired
    private KaiGongService kaiGongService;
    @Autowired
    private ZaijianTisuService zaijianTisuService;
    @Autowired
    private JungongTouchanService jungongTouchanService;
    @Autowired
    private ZhaoShangProjectService zhaoshangService;



    @Autowired
    @Lazy(true)
    private ProjectFeedBackService feedBackService;


    @Override
    protected BaseDao<ExcelDataEntity, String> getDao() {
        return dao;
    }

    public List<ExcelDataEntity> getByBatchNum(String  number)
    {
        return dao.getDataByNum(number);
    }

    @Override
    protected void beforeSave(ExcelDataEntity obj) {
        obj.setSysId( sysTableService.updateMaxSysId("t_excel_data",null));
    }


    public String savebatchExcelData(List<ExcelDataEntity> lists)
    {

        long time = System.currentTimeMillis();
        String batchNum = time+"";
        this.batchSave(lists);
        return  batchNum;

    }

    /**
     * 内部立项保存到Excel转为 子任务类
     */
    public List<InsideSubTaskFilter> excelToInsideEntity(List<ExcelDataEntity> list)
    {
        List<InsideSubTaskFilter> listInsides = new ArrayList<>();
        Calendar ca = Calendar.getInstance();
        for (ExcelDataEntity entity : list) {
            InsideSubTaskFilter subtask = new InsideSubTaskFilter();
            subtask.setSubTaskName(entity.getCell0());
            subtask.setUserId(entity.getCell6());
            //设置周期性
            //设置时限；
            String timeType = entity.getCell3();//周期类型
            String timeValue = entity.getCell4();//时限
            String cycleValue ="";
            switch (timeType){
                case "多时限":
                    subtask.setTimeLimits(timeValue);
                    subtask.setTimeType(3);
                    break;
                case "单时限":
                    subtask.setTimeType(1);
                    subtask.setSubTimeLimit(timeValue);
                    break;
                case "天":
                    subtask.setTimeType(2);
                    subtask.setPeriod(0+"");
                    String  subDate="";
                    int addnum =0;
                    try {

                        addnum = Integer.parseInt(timeValue);
                        ca.add(Calendar.DATE,addnum);
                        subDate = net.huashitong.util.DateUtil.DateToStr(ca.getTime());
                    }catch (Exception e){
                        //  wrong="周期性:天，【时限】格式填写错误,正确的格式直接填写天数即可。例如：3";
                        break;
                    }
                    subtask.setDay(addnum+"");
                    subtask.setSubTimeLimit(subDate);
                    break;
                case "周":
                    subtask.setTimeType(2);
                    subtask.setPeriod("1");
                    int weeks = ca.get(Calendar.DAY_OF_WEEK);
                    int wk= net.huashitong.util.DateUtil.weekToInt(timeValue);
                    if(wk==0){
                        // wrong="周期性：周：【时限】格式填写错误，正确格式例子：星期三";
                        break;
                    }

                    wk=wk+1;
                    int abs = Math.abs(weeks - wk);
                    ca.add(Calendar.DATE,abs);
                    subDate = net.huashitong.util.DateUtil.DateToStr(ca.getTime());
                    subtask.setWeek(wk+"");
                    subtask.setSubTimeLimit(subDate);
                    break;
                case "月":
                    subtask.setTimeType(2);
                    subtask.setPeriod("2");

                    cycleValue=timeValue;
                    int currDay = ca.get(Calendar.DAY_OF_MONTH);
                    int temDay =0;
                    try {

                        temDay=Integer.parseInt(timeValue);
                    }catch (Exception e)
                    {
                        System.out.println("月：参数错误");
                        // wrong = "周期性：月，【格式】格式填写错误，正确的格式例子：03";
                        break;
                    }

                    String currentMonth = net.huashitong.util.DateUtil.getCurrentMonth();

                    if (currDay-temDay>0) {
                        //提醒日期在  早于 今天，提醒日期设置为下个月的
                        ca.add(Calendar.MONTH,1);
                        ca.getTime();
                        int maximum = ca.getActualMaximum(Calendar.DAY_OF_MONTH);
                        int year = ca.get(Calendar.YEAR);
                        int month2 =ca.get(Calendar.MONTH)+1;
                        if(maximum-temDay<=0){//考虑2月情况
                            subDate=year+"-"+month2+"-"+maximum;
                        }else {
                            subDate=year+"-"+month2+"-"+temDay;
                        }
                    }else {
                        subDate= currentMonth+"-"+temDay;
                    }

                    subtask.setMonth(cycleValue);
                    subtask.setSubTimeLimit(subDate);
                    break;
                case "季度":
                    subtask.setTimeType(2);
                    subtask.setPeriod("3");
                    cycleValue=timeValue;
                    Date alertDate = net.huashitong.util.DateUtil.strToDate(cycleValue);
                    if(null==alertDate){
                        // wrong="周期性：季度；【时限】格式填写错误，正确格式为yyyy-MM-dd 例如：2020-12-07";
                        break;
                    }
                    Date currDate = net.huashitong.util.DateUtil.strToDate(net.huashitong.util.DateUtil.getCurrentDate());
                    if (alertDate.compareTo(currDate)>0) {
                        //提醒日期 是否晚于 今天 如果晚于的话，直接设置。
                        subDate = cycleValue;
                    }else {
                        //下一个季度
                        ca.setTime(alertDate);
                        ca.add(Calendar.MONTH,3);
                        subDate = DateUtil.DateToStr(ca.getTime());
                    }
                    subtask.setQuarter(cycleValue);
                    subtask.setSubTimeLimit(subDate);
                    break;
                default:
                    subtask.setTimeType(1);
                    break;

            }

            listInsides.add(subtask);
            //---end --
        }


        return listInsides;
    }

    /**
     * 普通立项Excel数据转为  子任务
     * @param list
     */
    public List<TaskSubFilter> ExceltoEntity(List<ExcelDataEntity> list)
    {

        List<TaskSubFilter> listSubs = new ArrayList<>();
//        Calendar ca = Calendar.getInstance();
        //时间为空就默认当前时间

        for (ExcelDataEntity entity : list) {
            TaskSubFilter taskSubFilter  = new TaskSubFilter();
            taskSubFilter.setSubName(entity.getCell0());//设置事项

            //设置时限；
            String timeType = entity.getCell3();//周期类型
            String timeValue = entity.getCell4();//时限
//            String cycleValue ="";
            //设置时间格式
            setTimetypeAndLimint(taskSubFilter,timeType,timeValue);
            //---end --

            //抄送领导；
            taskSubFilter.setSubCopeToIds(entity.getCell8());

            //牵头单位
            taskSubFilter.setLeadDeptIds(entity.getCell6());
            //协办
            taskSubFilter.setAssistDeptIds(entity.getCell7());

            //督查组id
            taskSubFilter.setInspectionId(entity.getCell10().replace(",",""));
            listSubs.add(taskSubFilter);


        }

        return listSubs;

    }

    public int setTimetypeAndLimint(TaskSubFilter  taskSubFilter,String timeType,String timeValue)
    {
        int code =1;
        Calendar ca = Calendar.getInstance();
        String cycleValue ="";
        switch (timeType){
            case "多时限":
                taskSubFilter.setTimeLimits(timeValue);
                taskSubFilter.setTimeType("3");
                break;
            case "单时限":
                taskSubFilter.setTimeType("1");
                taskSubFilter.setSubTimeLimit(timeValue);
                break;
            case "天":
                taskSubFilter.setTimeType("2");
                taskSubFilter.setPeriod("0");
                String  subDate="";
                int addnum =0;
                try {

                    addnum = Integer.parseInt(timeValue);
                    ca.add(Calendar.DATE,addnum);
                    subDate = net.huashitong.util.DateUtil.DateToStr(ca.getTime());
                }catch (Exception e){
                    //  wrong="周期性:天，【时限】格式填写错误,正确的格式直接填写天数即可。例如：3";
                    code=  0;
                }
                taskSubFilter.setDay(addnum+"");
                taskSubFilter.setSubTimeLimit(subDate);
                break;
            case "周":
                taskSubFilter.setTimeType("2");
                taskSubFilter.setPeriod("1");
                int weeks = ca.get(Calendar.DAY_OF_WEEK);
                int wk= net.huashitong.util.DateUtil.weekToInt(timeValue);
                if(wk==0){
                    // wrong="周期性：周：【时限】格式填写错误，正确格式例子：星期三";
                    wk=Integer.parseInt(timeValue);

                }

                wk=wk+1;
                int abs =0;
                if (weeks-wk>0) {
                 abs=1+wk;
                }else {

                    abs = Math.abs(weeks - wk);
                }

                ca.add(Calendar.DATE,abs);
                subDate = net.huashitong.util.DateUtil.DateToStr(ca.getTime());
                taskSubFilter.setWeek(wk+"");
                taskSubFilter.setSubTimeLimit(subDate);
                break;
            case "月":
                taskSubFilter.setTimeType("2");
                taskSubFilter.setPeriod("2");

                cycleValue=timeValue;
                int currDay = ca.get(Calendar.DAY_OF_MONTH);
                int temDay =0;
                try {

                    temDay=Integer.parseInt(timeValue);
                }catch (Exception e)
                {
                    System.out.println("月：参数错误");
                    // wrong = "周期性：月，【格式】格式填写错误，正确的格式例子：03";
                    code= 0;
                }

                String currentMonth = net.huashitong.util.DateUtil.getCurrentMonth();

                if (currDay-temDay>0) {
                    //提醒日期在  早于 今天，提醒日期设置为下个月的
                    ca.add(Calendar.MONTH,1);
                    ca.getTime();
                    int maximum = ca.getActualMaximum(Calendar.DAY_OF_MONTH);
                    int year = ca.get(Calendar.YEAR);
                    int month2 =ca.get(Calendar.MONTH)+1;
                    if(maximum-temDay<=0){//考虑2月情况
                        subDate=year+"-"+month2+"-"+maximum;
                    }else {
                        subDate=year+"-"+month2+"-"+temDay;
                    }
                }else {
                    subDate= currentMonth+"-"+temDay;
                }

                taskSubFilter.setMonth(cycleValue);
                taskSubFilter.setSubTimeLimit(subDate);
                break;
            case "季度":
                taskSubFilter.setTimeType("2");
                taskSubFilter.setPeriod("3");
                cycleValue=timeValue;
                Date alertDate = net.huashitong.util.DateUtil.strToDate(cycleValue);
                if(null==alertDate){
                    // wrong="周期性：季度；【时限】格式填写错误，正确格式为yyyy-MM-dd 例如：2020-12-07";
                    code = 0;
                }
                Date currDate = net.huashitong.util.DateUtil.strToDate(net.huashitong.util.DateUtil.getCurrentDate());
                if (alertDate.compareTo(currDate)>0) {
                    //提醒日期 是否晚于 今天 如果晚于的话，直接设置。
                    subDate = cycleValue;
                }else {
                    //下一个季度
                    ca.setTime(alertDate);
                    ca.add(Calendar.MONTH,3);
                    subDate = DateUtil.DateToStr(ca.getTime());
                }
                taskSubFilter.setQuarter(cycleValue);
                taskSubFilter.setSubTimeLimit(subDate);
                break;
            default:
                taskSubFilter.setTimeType("1");
                break;

        }

        return  code;
    }


    /**
     *普通立项 读取数据
     */
    public  List<ExcelDataEntity> importDatas(InputStream inputStream,String name) throws IOException, InvalidFormatException {

        Workbook workbook = WorkbookFactory.create(inputStream);
        Sheet sheet = workbook.getSheetAt(0);
        Row row = sheet.getRow(0);
        row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
        String va0 = row.getCell(0).getStringCellValue();//事项

        row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
        String va1 = row.getCell(1).getStringCellValue();//牵头单位和协办单位

        row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
        String va2 = row.getCell(2).getStringCellValue();//周期类型

        row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
        String va3 = row.getCell(3).getStringCellValue();//时限

        row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
        String va4 = row.getCell(4).getStringCellValue();//领导


        List<ExcelDataEntity> list  = new ArrayList<>();
        if(!"事项".equals(va0)||!"周期类型".equals(va2)||!"时限".equals(va3)){
            System.out.println("表头不对劲");
            return null;
        }

        int lastRow = sheet.getPhysicalNumberOfRows();//获取最大行数
        for (int i = 1; i < lastRow; i++) {
            ExcelDataEntity entity = new ExcelDataEntity();
            Row row2 = sheet.getRow(i);

            Cell cell0 = row2.getCell(0);
            if(null ==cell0){
                cell0 = row2.createCell(0);
            }
            cell0.setCellType(Cell.CELL_TYPE_STRING);
            String cellValue0 = cell0.getStringCellValue(); //事件

            entity.setCell0(cellValue0);//事件


            //单位
            Cell cell1 = row2.getCell(1);
            if(null ==cell1)
            {
                cell1 = row2.createCell(1);
            }
            cell1.setCellType(Cell.CELL_TYPE_STRING);
            String cellValue1 = cell1.getStringCellValue();
            entity.setCell1(cellValue1);//单位




            //周期类型
            Cell cell2 = row2.getCell(2);
            if(null ==cell2)
            {
                cell2 = row2.createCell(2);
            }
            cell2.setCellType(Cell.CELL_TYPE_STRING);
            String cellValue2 = cell2.getStringCellValue();

            entity.setCell3(cellValue2);//周期


            //时限
            Cell cell3 = row2.getCell(3);
            if(null ==cell3)
            {
                cell3 = row2.createCell(3);
            }
            cell3.setCellType(Cell.CELL_TYPE_STRING);
            String cellValue3 = cell3.getStringCellValue();

            entity.setCell4(cellValue3);//时限

            //抄送领导
            Cell cell4 = row2.getCell(4);
            if(null ==cell4)
            {
                cell4 = row2.createCell(4);
            }
            cell4.setCellType(Cell.CELL_TYPE_STRING);
            String cellValue4 = cell4.getStringCellValue();
            entity.setCell5(cellValue4);//抄送领导

            list.add(entity);

        }
        //倒序
        Collections.reverse(list);
        return  list;

    }

    /**
     * 普通立项
     *  校验并保存
     * @param list
     * @return
     */
    public List<ExcelDataEntity> saveData(List<ExcelDataEntity> list)
    {
        String batchNum = System.currentTimeMillis()+"";
        for (ExcelDataEntity entity : list) {

            entity.setFlags(1);
            entity.setBatchNum(batchNum);
            String cell1 = entity.getCell1();//分割单位

            String[] splitUnit = cell1.split("，");
            entity.setCell1(splitUnit[0].replace("牵头",""));//去掉多余的中文字 比如"牵头"
            if (splitUnit.length>1) {
                entity.setCell2(splitUnit[1].replace("配合",""));//去掉多余的字 比如"协办"
            }
            //牵头
            if(StringUtils.isNotBlank(entity.getCell1())){
                String ids = matchDept(entity.getCell1(), entity);
                entity.setCell6(ids);//存放牵头单位id

            }
            if(StringUtils.isBlank(entity.getCell6()))
            {
                entity.setFlags(0);
                entity.setRemarks(entity.getRemarks()==null?"牵头单位不能为空\n":entity.getRemarks()+";\n牵头单位不能为空");
            }
            //协办
            if(StringUtils.isNotBlank(entity.getCell2()))
            {
                String ids = matchDept(entity.getCell2(), entity);
                entity.setCell7(ids);//存放协办单位id
            }
            if(StringUtils.isNotBlank(entity.getCell6())&&StringUtils.isNotBlank(entity.getCell7()))
            {
                if (containSameId(entity.getCell6(),entity.getCell7())) {
                    entity.setFlags(0);
                    entity.setRemarks(entity.getRemarks()==null?"牵头单位和协办单位不能为同个单位":entity.getRemarks()+";\n牵头单位和协办单位不能为同个单位");
                }
            }

            String cell3 = entity.getCell3();
            if("多时限".equals(cell3))
            {
                String cell4 = entity.getCell4();
                cell4=cell4.replace("，",",");
                entity.setCell4(cell4);
            }

            String str = matchTimeType(cell3, entity.getCell4());
            if(""!=str)
            {
                entity.setRemarks(StringUtils.isBlank(entity.getRemarks())?str:entity.getRemarks()+str);
                entity.setFlags(0);
            }

            if(StringUtils.isNotBlank(entity.getCell5())){

                //校验领导
                List<SysUser> sysUsers = sysUserService.getbyName(entity.getCell5());
                if(ObjectUtils.isBlank(sysUsers))
                {
                    entity.setFlags(0);
                    entity.setRemarks(entity.getRemarks()==null?"无法匹配到该领导":entity.getRemarks()+"\n 无法匹配到该领导");
                }else {
                    if(sysUsers.size()>1){
                        entity.setFlags(0);
                        entity.setRemarks(entity.getRemarks()==null?"匹配到领导重复多个，请手动匹配":entity.getRemarks()+"; 匹配到领导重复多个，请手动匹配");
                    }else {
                        SysUser user = sysUsers.get(0);
                        SysLogin loginUser = loginService.getById(user.getSysId());
                        String roleId = loginUser.getRoleId();
                        if(!"02".equals(roleId)){
                            entity.setFlags(0);
                            entity.setRemarks(entity.getRemarks()==null?"抄送领导所填用户不是领导角色":entity.getRemarks()+";\n 抄送领导所填用户不是领导角色");

                        }else {
                            entity.setCell8(user.getSysId());
                        }

                    }
                }
            }

            System.out.println("================"+entity.getCell5());

        }
        // System.out.println(list.size());

        this.batchSave(list);
        String userId = SysUserUtils.getUserId();
        redisService.set("batchNum:"+userId,batchNum);
        return list;
    }


    public boolean containSameId(String id1,String id2)
    {
        String[] arr1 = id1.split(",");
        String[] arr2 = id2.split(",");
        HashMap<String,String> dmap = new HashMap<>();
        for (String s : arr1) {
            dmap.put(s,s);
        }
        for (String s : arr2) {
            if (dmap.containsKey(s)) {
                    return true;
            }

        }
        return  false;
    }



    /**
     * 内部立项
     * 数据处理 保存
     * @param list
     */
    public List<ExcelDataEntity>  saveInsideDataDeal(List<ExcelDataEntity> list )
    {
        String batchNum =System.currentTimeMillis()+"";
        for (ExcelDataEntity entity : list) {
            entity.setFlags(1);
            entity.setBatchNum(batchNum);
            String cell1 = entity.getCell1();//承办人
            String[] splitPeople = cell1.split(",");
            String  remark = "";
            if(ObjectUtils.isBlank(splitPeople)){
                remark  = remark+"承办人不能为空；";
                entity.setFlags(0);
                entity.setRemarks(remark);

            }else {
                for (String str : splitPeople) {
                    SysUserFilter filter = new SysUserFilter();
                    filter.setNameNotLike(1);
                    filter.setName(str);
                    List<SysUser> query = sysUserService.query(filter);
                    if(ObjectUtils.isBlank(query))
                    {
                        remark= remark+"根据["+str+"]无法匹配到该人员;\n";
                        entity.setRemarks(remark);
                        entity.setFlags(0);
                    }else {
                        if (query.size()>1) {
                            remark = remark+"'"+str+"根据姓名匹配到多人，请手动确定;\n";
                            entity.setRemarks(remark);
                            entity.setFlags(0);
                        }else {
                            entity.setCell6(query.get(0).getSysId());
                        }
                    }

                }
            }



            //周期类型


            //时限
            String cell3 = entity.getCell3();
            if("多时限".equals(cell3))
            {
                String cell4 = entity.getCell4();
                cell4=cell4.replace("，",",");
                entity.setCell4(cell4);
            }


            String str = matchTimeType(cell3, entity.getCell4());
            if(""!=str){
                entity.setRemarks(str);
                entity.setFlags(0);
            }

        }
        batchSave(list);
        String userId = SysUserUtils.getUserId();

        redisService.set("insideBatch:"+userId,batchNum);

        return list;
    }

    /**
     * 内部单位导入子任务-处理数据
     */
    public  List<ExcelDataEntity> insideImportDatas(InputStream inputStream,String name) throws IOException, InvalidFormatException {

        Workbook workbook = WorkbookFactory.create(inputStream);
        Sheet sheet = workbook.getSheetAt(0);
        Row row = sheet.getRow(0);
        row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
        String va0 = row.getCell(0).getStringCellValue();//事项

        row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
        String va1 = row.getCell(1).getStringCellValue();//承办人

        row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
        String va2 = row.getCell(2).getStringCellValue();//周期类型

        row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
        String va3 = row.getCell(3).getStringCellValue();//时限


        List<ExcelDataEntity> list  = new ArrayList<>();
        if(!"事项".equals(va0)||!"承办人".equals(va1)||!"周期类型".equals(va2)||!"时限".equals(va3)){
            System.out.println("表头不对劲");
            return list;
        }

        int lastRow = sheet.getPhysicalNumberOfRows();//获取最大行数
        for (int i = 1; i < lastRow; i++) {
            ExcelDataEntity entity = new ExcelDataEntity();
            Row row2 = sheet.getRow(i);

            Cell cell0 = row2.getCell(0);
            if(null ==cell0){
                cell0 = row2.createCell(0);
            }
            cell0.setCellType(Cell.CELL_TYPE_STRING);
            String cellValue0 = cell0.getStringCellValue(); //事件

            entity.setCell0(cellValue0);//事件


            //承办人
            Cell cell1 = row2.getCell(1);
            if(null ==cell1)
            {
                cell1 = row2.createCell(1);
            }
            cell1.setCellType(Cell.CELL_TYPE_STRING);
            String cellValue1 = cell1.getStringCellValue();
            entity.setCell1(cellValue1);//承办人




            //周期类型
            Cell cell2 = row2.getCell(2);
            if(null ==cell2)
            {
                cell2 = row2.createCell(2);
            }
            cell2.setCellType(Cell.CELL_TYPE_STRING);
            String cellValue2 = cell2.getStringCellValue();

            entity.setCell3(cellValue2);//周期


            //时限
            Cell cell3 = row2.getCell(3);
            if(null ==cell3)
            {
                cell3 = row2.createCell(3);
            }
            cell3.setCellType(Cell.CELL_TYPE_STRING);
            String cellValue3 = cell3.getStringCellValue();

            entity.setCell4(cellValue3);//时限

            //抄送领导
            Cell cell4 = row2.getCell(4);
            if(null ==cell4)
            {
                cell4 = row2.createCell(4);
            }
            cell4.setCellType(Cell.CELL_TYPE_STRING);
            String cellValue4 = cell4.getStringCellValue();
            entity.setCell5(cellValue4);//抄送领导

            list.add(entity);

        }
        //倒序
        Collections.reverse(list);
        return  list;

    }



    /**
     * 匹配单位
     * @param depts
     * @param entity
     * @return
     */
    public String matchDept(String depts, ExcelDataEntity entity)
    {
        //String qtUnit = entity.getCell1();
        String[] splitQt = depts.split("、");
        String unitId ="";
        for (String s : splitQt) {
            List<SysDept> query = deptService.getByName(s);
            if(ObjectUtils.isBlank(query))
            {
                entity.setRemarks("'"+s+"'");
                entity.setFlags(0);
                continue;
            }
            unitId=unitId+query.get(0).getSysId()+",";

        }
        if(StringUtils.isNotBlank(entity.getRemarks()))
        {
            entity.setRemarks(entity.getRemarks()+"单位匹配失败，请手动匹配");
        }
        return  unitId;
        // entity.setCell6(unitId);//牵头id
    }



    /**
     * 校验周期性 和是时限
     * @param
     * @param
     */
    public String   matchTimeType(String timeType ,String timeValue){

        String remark ="";
        boolean flags =true;
        switch (timeType){
            case "多时限":
                timeValue =timeValue.replace("，",",");
                String[] splitTimeLimits = timeValue.split(",");

                if(ObjectUtils.isBlank(splitTimeLimits)){
                    remark="时限不能为空";
                }else {
                    for (String str : splitTimeLimits) {
                        try {
                             str =str.replace("\n","");

                             flags = DateUtil.validDateEffecitive(str);
                        } catch (Exception e) {
                            remark=remark+"【"+str.replace("\\n","")+"】时限格式错误，【多时限】时限格式为：yyyy-MM-dd的时间格式;\n";
                        }
                        if (!flags){
                            remark=remark+"【"+str.replace("\\n","")+"】时限格式错误，时限转化错误，请正确填写日期格式和日期范围;\n";
                        }
                    }
                }
                break;
            case "单时限":

                try {
                   flags= DateUtil.validDateEffecitive(timeValue);
                } catch (Exception e) {
                    remark=remark+"【" +timeValue+"】时限格式错误，【单时限】时限格式为：yyyy-MM-dd的时间格式;\n";
                }
                if(!flags){
                    remark=remark+"【"+timeValue+"】时限格式错误，时限转化错误，请正确填写日期格式和日期范围;\n";

                }

                break;
            case "天":
                int addnum =0;
                try {

                    addnum = Integer.parseInt(timeValue);
                    if(addnum==0){
                        remark=remark+"【" +timeValue +"】时限格式错误，周期性为【天】的时限格式为大于1的纯数字，例如：20;\n";

                    }
                }catch (Exception e){
                    remark=remark+"【" +timeValue +"】时限格式错误，周期性为【天】的时限格式为纯数字，例如：20;\n";
                }


                break;
            case "周":
                int i = DateUtil.weekToInt(timeValue);
                if(0==i){
                    remark = remark+"【"+timeValue+"】时限格式错误，周期性为【周】的时限格式为以'星期'开头，例如：星期天;\n";
                }
                break;
            case "月":


                int temDay =0;
                try {

                    temDay=Integer.parseInt(timeValue);
                }catch (Exception e)
                {
                    remark=remark+"【" + timeValue+"】时限格式错误，周期性为【月】的时限格式为1-31之间的数字;\n";

                    // wrong = "周期性：月，【格式】格式填写错误，正确的格式例子：03";
                    break;
                }

                if(temDay<=0||temDay>31){
                    remark=remark+"【" + timeValue+"】时限格式错误，周期性为【月】的时限格式为1-31之间的数字;\n";
                }


                break;
            case "季度":
                try {
                    flags= DateUtil.validDateEffecitive(timeValue);
                } catch (Exception e) {
                    remark=remark+"【" + timeValue+"】时限格式错误，周期性为【季度】时限格式为：yyyy-MM-dd的时间格式;\n";
                }
                if(!flags){
                    remark=remark+"【" + timeValue+"】时限格式错误，时限转化错误，请正确填写日期格式和日期范围;\n";
                }
                break;
            default:
                remark=remark+"周期类型错误。周期类型分别为：多时限、单时限、天、周、月、季度;\n";
                break;

        }

        return  remark;
    }


    /**
     * 攻坚任务 -读取攻坚数据
     */
    public List<ExcelDataEntity> readDataOfGongJian(InputStream inputStream,String name) throws IOException, InvalidFormatException {
        Workbook workbook = WorkbookFactory.create(inputStream);
        Sheet sheet = workbook.getSheetAt(0);
        Row row = sheet.getRow(0);
        row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
        String va0 = row.getCell(0).getStringCellValue();//事项

        row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
        String va1 = row.getCell(1).getStringCellValue();//牵头单位和协办单位

        row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
        String va2 = row.getCell(2).getStringCellValue();//周期类型

        row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
        String va3 = row.getCell(3).getStringCellValue();//时限

      /*  row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
        String va4 = row.getCell(4).getStringCellValue();//领导
*/
        row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
        String va4 = row.getCell(4).getStringCellValue();//督查组


        List<ExcelDataEntity> list  = new ArrayList<>();
        if(StringUtils.isBlank(va0)||StringUtils.isBlank(va1)
         ||StringUtils.isBlank(va2)||StringUtils.isBlank(va3)
         ||StringUtils.isBlank(va4) ){
            System.out.println("表头不对");
            return list;
        }
        int lastRow = sheet.getPhysicalNumberOfRows();
        for (int i = 1; i < lastRow; i++) {
            ExcelDataEntity entity  = new ExcelDataEntity();
            Row dataRow = sheet.getRow(i);
            Cell shiXiang = dataRow.getCell(0);
            if(null==shiXiang)
            {
                shiXiang = dataRow.createCell(0);
            }
            String strShiXiang = shiXiang.getStringCellValue();
            entity.setCell0(strShiXiang);

            Cell danWei = dataRow.getCell(1);
            if(null==danWei)
            {
                danWei=dataRow.createCell(1);
            }
            String strDanWei = danWei.getStringCellValue();
            entity.setCell1(strDanWei);

            Cell zhouQi = dataRow.getCell(2);
            if(null == zhouQi)
            {
                zhouQi = dataRow.getCell(2);
            }
            String StrZhouQi = zhouQi.getStringCellValue();
            entity.setCell3(StrZhouQi);

            Cell shiXian = dataRow.getCell(3);
            if(null == shiXian)
            {
                shiXian = dataRow.createCell(3);
            }
            try {
                String strShiXian = shiXian.getStringCellValue();
                entity.setCell4(strShiXian.trim());

            }catch (Exception e){
                double numericCellValue = shiXian.getNumericCellValue();
                int ce4Value = (int) numericCellValue;
                entity.setCell4(ce4Value+"");

            }
           // String strShiXian = shiXian.getStringCellValue();

            Cell duChaZu = dataRow.getCell(4);
            if(null==duChaZu)
            {
                duChaZu=dataRow.createCell(4);
            }
            String strDuChaZu = duChaZu.getStringCellValue();
            entity.setCell9(strDuChaZu);

            list.add(entity);


        }
        Collections.reverse(list);
        return list ;
    }

    /**
     * 攻坚任务
     * 校验数据 并保存
     *
     */
    public List<ExcelDataEntity> saveDataGongJian(List<ExcelDataEntity> list)
    {
        //生成批次号
        String batchNum = System.currentTimeMillis()+"";

        for (ExcelDataEntity entity : list) {
            entity.setFlags(1);
            entity.setBatchNum(batchNum);
            String cell1 = entity.getCell1();//分割单位

            String[] splitUnit = cell1.split("，");
            entity.setCell1(splitUnit[0].replace("牵头",""));//去掉多余的中文字 比如"牵头"
            if (splitUnit.length>1) {
                entity.setCell2(splitUnit[1].replace("配合",""));//去掉多余的字 比如"协办"
            }
            //牵头
            if(StringUtils.isNotBlank(entity.getCell1())){
                String ids = matchDept(entity.getCell1(), entity);
                entity.setCell6(ids);//存放牵头单位id

            }
            if(StringUtils.isBlank(entity.getCell6()))
            {
                entity.setFlags(0);
                entity.setRemarks(entity.getRemarks()==null?"牵头单位不能为空\n":entity.getRemarks()+";\n牵头单位不能为空");
            }
            //协办
            if(StringUtils.isNotBlank(entity.getCell2()))
            {
                String ids = matchDept(entity.getCell2(), entity);
                entity.setCell7(ids);//存放协办单位id
            }
            if(StringUtils.isNotBlank(entity.getCell6())&&StringUtils.isNotBlank(entity.getCell7()))
            {
                if (containSameId(entity.getCell6(),entity.getCell7())) {
                    entity.setFlags(0);
                    entity.setRemarks(entity.getRemarks()==null?"牵头单位和协办单位不能为同个单位":entity.getRemarks()+";\n牵头单位和协办单位不能为同个单位");
                }
            }

            String cell3 = entity.getCell3();
            if("多时限".equals(cell3))
            {
                String cell4 = entity.getCell4();
                cell4=cell4.replace("，",",");
                entity.setCell4(cell4);
            }

            String str = matchTimeType(cell3, entity.getCell4());
            if(""!=str)
            {
                entity.setRemarks(StringUtils.isBlank(entity.getRemarks())?str:entity.getRemarks()+str);
                entity.setFlags(0);
            }

            //督查组
            if(StringUtils.isNotBlank(entity.getCell9())){
                String duchaIds = matchDept(entity.getCell9(), entity);
                entity.setCell10(duchaIds);
            }




        }

        this.batchSave(list);
        String userId = SysUserUtils.getUserId();
        redisService.set("gongjianBatch:"+userId,batchNum);


        return  list;
    }


    /**
     * 攻坚120天任务
     * @param projectType
     * @return
     */
    public List<FeedBackDTO> getnewGongjianData(int projectType)
    {
        List<FeedBackDTO> dataList = new ArrayList<>();

        switch ( projectType)
        {
            case 1://征地拆迁

                List<ZhengQianEntity> list = zhengQianService.getList(new ZhengQianFilter());
                for (ZhengQianEntity item : list) {
                    FeedBackDTO dto  = new FeedBackDTO();
                    BeanUtils.copyProperties(item,dto);
                    dto.setProjId(item.getSysId());
                    dto.setLevel(0);
                    dto.setIsLeaf(true);
                    dto.setExpanded(true);
                    dto.setSysId(item.getSysId());
                    dto.setProjectId(item.getSysId());

                    List<ProjectFeedBackEntity> backList = feedBackService.getCurrentFeedBackList(item.getSysId(), 1, 1,null);
                    if(!CollectionUtils.isEmpty(backList)){
                        if(backList.size()>1){
                            List<FeedBackDTO> treeList = new ArrayList<>();
                            int index=1;
                            for (ProjectFeedBackEntity feedback : backList) {

                                FeedBackDTO itemDto  = new FeedBackDTO();

                                itemDto.setCurrentBack(item.getCurrentBack());
                                itemDto.setProjectName("      "+"("+index+")"+item.getProjectName());
                                itemDto.setLevel(1);
                                itemDto.setIsLeaf(true);
                                itemDto.setParent(item.getSysId());
                                itemDto.setExpanded(true);
                                itemDto.setSysId(feedback.getSysId());
                                itemDto.setProjId(item.getSysId());
                                itemDto.setProjectId(item.getSysId());
                                itemDto.setFeedbackId(feedback.getSysId());
                                itemDto.setBackRemark(feedback.getRemarks());
                                itemDto.setReachoals(feedback.getReachoals());
                                itemDto.setXingxiang(feedback.getXingxiang());
                                itemDto.setCurrentMianji(feedback.getCurrentMianji());
                                itemDto.setFinishMianji(feedback.getFinishMianji());
                                itemDto.setCurrentChaiqian(feedback.getFinishChaiqian());
                                itemDto.setFinishChaiqian(feedback.getFinishChaiqian());
                                itemDto.setCurrentZhengqianhu(feedback.getCurrentZhengqianhu());
                                itemDto.setFinishZhengqianhu(feedback.getFinishZhengqianhu());
                                int zhengdiAudit = feedback.getZhengdiAudit();
                                itemDto.setCreateName(feedback.getCreateName());
                                itemDto.setCreateDate(feedback.getCreateDate()+" "+feedback.getCreateTime());
//                                String a1 = auditName(zhengdiAudit);
//                                String a2 = auditName(feedback.getChaiqianAudit());
//                                itemDto.setAuditInfo("征地审核："+a1+"\n"+"拆迁审核："+a2);
                                treeList.add(itemDto);
                                index=index+1;
                            }
                            dto.setIsLeaf(false);
                            dto.setTreeList(treeList);
                            dataList.add(dto);
                        }else {
                            dto.setSysId(backList.get(0).getSysId());
                            dto.setProjId(item.getSysId());
                            dto.setProjectId(item.getSysId());
                            dto.setFeedbackId(backList.get(0).getSysId());
                            dto.setBackRemark(backList.get(0).getRemarks());
                            dto.setCurrentMianji(backList.get(0).getCurrentMianji());
                            dto.setFinishMianji(backList.get(0).getFinishMianji());
                            dto.setCurrentChaiqian(backList.get(0).getFinishChaiqian());
                            dto.setFinishChaiqian(backList.get(0).getFinishChaiqian());
                            dto.setCurrentZhengqianhu(backList.get(0).getCurrentZhengqianhu());
                            dto.setFinishZhengqianhu(backList.get(0).getFinishZhengqianhu());
                            dto.setReachoals(backList.get(0).getReachoals());
                            dto.setXingxiang(backList.get(0).getXingxiang());
                            int zhengdiAudit = backList.get(0).getZhengdiAudit();
                            dto.setCreateName(backList.get(0).getCreateName());
                            dto.setCreateDate(backList.get(0).getCreateDate()+" "+backList.get(0).getCreateTime());
//                            String a1 = auditName(zhengdiAudit);
//                            String a2 = auditName(backList.get(0).getChaiqianAudit());
//                            dto.setAuditInfo("征地审核："+a1+"\n"+"拆迁审核："+a2);
                            dataList.add(dto);
                        }


                    }else {
                        dataList.add(dto);
                    }
                }
                break;

            case 2:
                List<KaiGongEntity> kaigonglist = kaiGongService.getList(new KaiGongFilter());
                for (KaiGongEntity item : kaigonglist) {
                    FeedBackDTO dto  = new FeedBackDTO();
                    BeanUtils.copyProperties(item,dto);
                    dto.setProjId(item.getSysId());
                    dto.setLevel(0);
                    dto.setIsLeaf(true);
                    dto.setExpanded(true);
                    dto.setSysId(item.getSysId());
                    dto.setProjectId(item.getSysId());

                    List<ProjectFeedBackEntity> backList = feedBackService.getCurrentFeedBackList(item.getSysId(), 1, 2,null);
                    if(!CollectionUtils.isEmpty(backList)){
                        if(backList.size()>1){
//                            dto.setIsLeaf(false);
//                            dataList.add(dto);
                            int index=1;
                            List<FeedBackDTO> treeList = new ArrayList<>();

                            for (ProjectFeedBackEntity feedback : backList) {

                                FeedBackDTO itemDto  = new FeedBackDTO();

                                itemDto.setCurrentBack(item.getCurrentBack());
                                itemDto.setProjectName("     "+"("+index+")"+item.getProjectName());
                                itemDto.setLevel(1);
                                itemDto.setIsLeaf(true);
                                itemDto.setParent(item.getSysId());
                                itemDto.setExpanded(true);
                                itemDto.setSysId(feedback.getSysId());
                                itemDto.setProjId(item.getSysId());
                                itemDto.setProjectId(item.getSysId());
                                itemDto.setFeedbackId(feedback.getSysId());
                                itemDto.setBackRemark(feedback.getRemarks());
                                itemDto.setReachoals(feedback.getReachoals());
                                itemDto.setXingxiang(feedback.getXingxiang());
                                itemDto.setKaigongState(feedback.getKaigongState());
                                itemDto.setCompletion(feedback.getCompletion());
                                itemDto.setKaigongState(feedback.getKaigongState());
                                itemDto.setCurrentValue(feedback.getCurrentValue());
                                itemDto.setTotalValue(feedback.getTotalValue());
                                itemDto.setCreateName(feedback.getCreateName());
                                itemDto.setAudit(feedback.getAudit());
                                treeList.add(itemDto);
                                index=index+1;
                            }
                            dto.setIsLeaf(false);
                            dto.setTreeList(treeList);
                            dataList.add(dto);
                        }else {
                            dto.setSysId(backList.get(0).getSysId());
                            dto.setProjId(item.getSysId());
                            dto.setProjectId(item.getSysId());
                            dto.setFeedbackId(backList.get(0).getSysId());
                            dto.setBackRemark(backList.get(0).getRemarks());
                            dto.setReachoals(backList.get(0).getReachoals());
                            dto.setXingxiang(backList.get(0).getXingxiang());
                            dto.setCompletion(backList.get(0).getCompletion());
                            dto.setKaigongState(backList.get(0).getKaigongState());
                            dto.setCurrentValue(backList.get(0).getCurrentValue());
                            dto.setTotalValue(backList.get(0).getTotalValue());
                            dto.setKaigongState(backList.get(0).getKaigongState());
                            dto.setCreateName(backList.get(0).getCreateName());
                            dto.setAudit(backList.get(0).getAudit());
                            dataList.add(dto);
                        }


                    }else {
                        dataList.add(dto);
                    }


                }
                break;
            case 3:
                List<ZaijianTisuEntity> zaijianlist = zaijianTisuService.getList(new ZaijianTisuFilter());
                for (ZaijianTisuEntity item : zaijianlist) {
                    FeedBackDTO dto  = new FeedBackDTO();
                    BeanUtils.copyProperties(item,dto);
                    dto.setProjId(item.getSysId());
                    dto.setLevel(0);
                    dto.setIsLeaf(true);
                    dto.setExpanded(true);
                    dto.setSysId(item.getSysId());
                    dto.setProjectId(item.getSysId());
                    List<ProjectFeedBackEntity> backList = feedBackService.getCurrentFeedBackList(item.getSysId(), 1, 3,null);
                    if(!CollectionUtils.isEmpty(backList)){
//                dto.setIsLeaf(false);
                        if(backList.size()>1){
                            dto.setIsLeaf(false);
//                            dataList.add(dto);
                            int index=1;
                            List<FeedBackDTO> treeList = new ArrayList<>();

                            for (ProjectFeedBackEntity feedback : backList) {

                                FeedBackDTO itemDto  = new FeedBackDTO();

                                itemDto.setCurrentBack(item.getCurrentBack());
                                itemDto.setProjectName("--->>"+"("+index+")"+item.getProjectName());
                                itemDto.setLevel(1);
                                itemDto.setIsLeaf(true);
                                itemDto.setParent(item.getSysId());
                                itemDto.setExpanded(true);
                                itemDto.setSysId(feedback.getSysId());
                                itemDto.setProjId(item.getSysId());
                                itemDto.setProjectId(item.getSysId());
                                itemDto.setFeedbackId(feedback.getSysId());
                                itemDto.setBackRemark(feedback.getRemarks());
                                itemDto.setReachoals(feedback.getReachoals());
                                itemDto.setXingxiang(feedback.getXingxiang());

                                itemDto.setCompletion(feedback.getCompletion());
                                itemDto.setKaigongState(feedback.getKaigongState());
                                itemDto.setCurrentValue(feedback.getCurrentValue());
                                itemDto.setTotalValue(feedback.getTotalValue());


                                treeList.add(itemDto);
                                index=index+1;
                            }
                            dto.setIsLeaf(false);
                            dto.setTreeList(treeList);
                            dataList.add(dto);
                        }else {
                            dto.setSysId(backList.get(0).getSysId());
                            dto.setProjId(item.getSysId());
                            dto.setProjectId(item.getSysId());
                            dto.setFeedbackId(backList.get(0).getSysId());
                            dto.setBackRemark(backList.get(0).getRemarks());

                            dto.setReachoals(backList.get(0).getReachoals());
                            dto.setXingxiang(backList.get(0).getXingxiang());
                            dto.setAddCurrentValue(backList.get(0).getAddCurrentValue());

                            dto.setCompletion(backList.get(0).getCompletion());
                            dto.setKaigongState(backList.get(0).getKaigongState());
                            dto.setCurrentValue(backList.get(0).getCurrentValue());
                            dto.setTotalValue(backList.get(0).getTotalValue());

                            dataList.add(dto);
                        }


                    }else {
                        dataList.add(dto);
                    }

                }
                break;
            case 4:
                //竣工
                List<JungongTouchanEntity> jungonglist = jungongTouchanService.getList(new JungongTouchanFilter());
                for (JungongTouchanEntity item : jungonglist) {
                    FeedBackDTO dto  = new FeedBackDTO();
                    BeanUtils.copyProperties(item,dto);
                    dto.setProjId(item.getSysId());
                    dto.setLevel(0);
                    dto.setIsLeaf(true);
                    dto.setExpanded(true);
                    dto.setSysId(item.getSysId());
                    dto.setProjectId(item.getSysId());

                    List<ProjectFeedBackEntity> backList = feedBackService.getCurrentFeedBackList(item.getSysId(), 1, 4,null);
                    if(!CollectionUtils.isEmpty(backList)){
//                dto.setIsLeaf(false);
                        if(backList.size()>1){
                            List<FeedBackDTO> treeList = new ArrayList<>();

                            int index=1;
                            for (ProjectFeedBackEntity feedback : backList) {

                                FeedBackDTO itemDto  = new FeedBackDTO();

                                itemDto.setCurrentBack(item.getCurrentBack());
                                itemDto.setProjectName("--->>"+"("+index+")"+item.getProjectName());
                                itemDto.setLevel(1);
                                itemDto.setIsLeaf(true);
                                itemDto.setParent(item.getSysId());
                                itemDto.setExpanded(true);
                                itemDto.setSysId(feedback.getSysId());
                                itemDto.setProjId(item.getSysId());
                                itemDto.setProjectId(item.getSysId());
                                itemDto.setFeedbackId(feedback.getSysId());
                                itemDto.setBackRemark(feedback.getRemarks());
                                itemDto.setReachoals(feedback.getReachoals());
                                itemDto.setXingxiang(feedback.getXingxiang());

//                        itemDto.setAddCurrentValue(feedback.getAddCurrentValue());

                                itemDto.setCompletion(feedback.getCompletion());
                                itemDto.setKaigongState(feedback.getKaigongState());
                                itemDto.setCurrentValue(feedback.getCurrentValue());
                                itemDto.setTotalValue(feedback.getTotalValue());
                                itemDto.setJungongState(feedback.getJungongState());
                                itemDto.setCreateName(feedback.getCreateName());
                                itemDto.setAudit(feedback.getAudit());
                                treeList.add(itemDto);
                                index=index+1;
                            }
                            dto.setIsLeaf(false);
                            dto.setTreeList(treeList);
                            dataList.add(dto);
                        }else {
                            dto.setSysId(backList.get(0).getSysId());
                            dto.setProjId(item.getSysId());
                            dto.setProjectId(item.getSysId());
                            dto.setFeedbackId(backList.get(0).getSysId());
                            dto.setBackRemark(backList.get(0).getRemarks());

                            dto.setReachoals(backList.get(0).getReachoals());
                            dto.setXingxiang(backList.get(0).getXingxiang());
                            dto.setAddCurrentValue(backList.get(0).getAddCurrentValue());
                            dto.setCreateName(backList.get(0).getCreateName());
                            dto.setAudit(backList.get(0).getAudit());

                            dto.setJungongState(backList.get(0).getJungongState());

                            dto.setCompletion(backList.get(0).getCompletion());
                            dto.setKaigongState(backList.get(0).getKaigongState());
                            dto.setCurrentValue(backList.get(0).getCurrentValue());
                            dto.setTotalValue(backList.get(0).getTotalValue());

                            dataList.add(dto);
                        }


                    }else {
                        dataList.add(dto);
                    }

                }
                break;

            case 5:
                List<ZhaoShangProjectEntity> zhaoshangList = zhaoshangService.getList(new ZhaoShangProjectFilter());
                for (ZhaoShangProjectEntity item : zhaoshangList) {
                    FeedBackDTO dto  = new FeedBackDTO();
                    BeanUtils.copyProperties(item,dto);
                    dto.setProjId(item.getSysId());
                    dto.setLevel(0);
                    dto.setIsLeaf(true);
                    dto.setExpanded(true);
                    dto.setSysId(item.getSysId());
                    dto.setProjectId(item.getSysId());
                    List<ProjectFeedBackEntity> backList = feedBackService.getCurrentFeedBackList(item.getSysId(), 1, 5,null);
                    if(!CollectionUtils.isEmpty(backList)){
//                dto.setIsLeaf(false);
                        if(backList.size()>1){
                            List<FeedBackDTO> treeList = new ArrayList<>();

                            int index=1;
                            for (ProjectFeedBackEntity feedback : backList) {

                                FeedBackDTO itemDto  = new FeedBackDTO();

                                itemDto.setCurrentBack(item.getCurrentBack());
                                itemDto.setProjectName("--->>"+"("+index+")"+item.getProjectName());
                                itemDto.setLevel(1);
                                itemDto.setIsLeaf(true);
                                itemDto.setParent(item.getSysId());
                                itemDto.setExpanded(true);
                                itemDto.setSysId(feedback.getSysId());
                                itemDto.setProjId(item.getSysId());
                                itemDto.setProjectId(item.getSysId());
                                itemDto.setFeedbackId(feedback.getSysId());
                                itemDto.setBackRemark(feedback.getRemarks());
                                itemDto.setReachoals(feedback.getReachoals());
                                itemDto.setXingxiang(feedback.getXingxiang());

                                itemDto.setAddCurrentValue(feedback.getAddCurrentValue());

                                itemDto.setCompletion(feedback.getCompletion());
                                itemDto.setKaigongState(feedback.getKaigongState());
                                itemDto.setCurrentValue(feedback.getCurrentValue());
                                itemDto.setTotalValue(feedback.getTotalValue());

                                itemDto.setCreateName(feedback.getCreateName());
                                itemDto.setAudit(feedback.getAudit());
                                treeList.add(itemDto);
                                index=index+1;
                            }
                            dto.setIsLeaf(false);
                            dto.setTreeList(treeList);
                            dataList.add(dto);
                        }else {
                            dto.setSysId(backList.get(0).getSysId());
                            dto.setProjId(item.getSysId());
                            dto.setProjectId(item.getSysId());
                            dto.setFeedbackId(backList.get(0).getSysId());
                            dto.setBackRemark(backList.get(0).getRemarks());
                            dto.setReachoals(backList.get(0).getReachoals());
                            dto.setXingxiang(backList.get(0).getXingxiang());
//                    dto.setAddCurrentValue(backList.get(0).getAddCurrentValue());
                            dto.setCreateName(backList.get(0).getCreateName());
                            dto.setAudit(backList.get(0).getAudit());
                            dto.setCompletion(backList.get(0).getCompletion());
                            dto.setKaigongState(backList.get(0).getKaigongState());
                            dto.setCurrentValue(backList.get(0).getCurrentValue());
                            dto.setTotalValue(backList.get(0).getTotalValue());

                            dataList.add(dto);
                        }


                    }else {
                        dataList.add(dto);
                    }

                }
                break;

            default:
                return null;



        }


        return dataList;
    }


    /**
     * 导出Excel
     * @param list
     * @param projectType
     * @return
     * @throws IOException
     * @throws InvalidFormatException
     */
    public Workbook exportGongJian(List<FeedBackDTO> list ,int projectType) throws IOException, InvalidFormatException {

        String path = "/";
        switch (projectType)
        {
            case 1:

                path=excelPath+"/zhengdichiqian.xlsx";
                break;
            case 2:
                path=excelPath+"/kaigong.xlsx";
                break;
            case 3:
                path=excelPath+"/zaijian.xlsx";
                break;
            case 4:
                path=excelPath+"/jungong.xlsx";
                break;
            case 5:
                path=excelPath+"/zhaoshang.xlsx";
                break;
            default:
                return null;
        }
        File file = new File(path);
        Workbook wb =WorkbookFactory.create(new FileInputStream(file));
        CellStyle style = wb.createCellStyle();
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);//居中格式
        style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
        style.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
        style.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
        style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
        Sheet sheet = wb.getSheetAt(0);

        int rowNum=0,index=0;
        switch (projectType)
        {
            case 1:
                 rowNum=4;
                for (FeedBackDTO feedBackDTO : list) {

                    ++index;
                    setZhengqianData(feedBackDTO,sheet,index+"",rowNum,style);
                    if(feedBackDTO.getTreeList()!=null&&feedBackDTO.getTreeList().size()>0){
                        List<FeedBackDTO> treeList = feedBackDTO.getTreeList();
                        int childIndex=1;
                        for (FeedBackDTO itemDto : treeList) {
                            rowNum=rowNum+1;
//                            ++index;
                            String ind= index+"-"+childIndex;
                            setZhengqianData(itemDto,sheet,ind,rowNum,style);
                            childIndex++;

                        }
                    }
                    rowNum++;
                }

                break;

            case 2:

                rowNum=3;
                for (FeedBackDTO feedBackDTO : list) {
                    ++index;
                    setKaigongData(feedBackDTO,sheet,index+"",rowNum,style);
                    if(feedBackDTO.getTreeList()!=null&&feedBackDTO.getTreeList().size()>0){
                        List<FeedBackDTO> treeList = feedBackDTO.getTreeList();
                        int childIndex=1;
                        for (FeedBackDTO itemDto : treeList) {
                            rowNum=rowNum+1;
//                            ++index;
                            String ind= index+"-"+childIndex;
                            setKaigongData(itemDto,sheet,ind,rowNum,style);
                            childIndex++;
                        }
                    }
                    rowNum++;
                }

                break;

            case 3:
                rowNum=3;
                for (FeedBackDTO feedBackDTO : list) {
                    ++index;
                    setZaiJianData(feedBackDTO,sheet,index+"",rowNum,style);
                    if(feedBackDTO.getTreeList()!=null&&feedBackDTO.getTreeList().size()>0){
                        List<FeedBackDTO> treeList = feedBackDTO.getTreeList();
                        int childIndex=1;
                        for (FeedBackDTO itemDto : treeList) {
                            rowNum=rowNum+1;
//                            ++index;
                            String ind= index+"-"+childIndex;
                            setZaiJianData(itemDto,sheet,ind,rowNum,style);
                            childIndex++;
                        }
                    }
                    rowNum++;
                }
                break;
            case 4://竣工
                rowNum=3;
                for (FeedBackDTO feedBackDTO : list) {
                    ++index;
                    setJungongData(feedBackDTO,sheet,index+"",rowNum,style);
                    if(feedBackDTO.getTreeList()!=null&&feedBackDTO.getTreeList().size()>0){
                        List<FeedBackDTO> treeList = feedBackDTO.getTreeList();
                        int childIndex=1;
                        for (FeedBackDTO itemDto : treeList) {
                            rowNum=rowNum+1;
                            String ind= index+"-"+childIndex;
                            setJungongData(itemDto,sheet,ind,rowNum,style);
                            childIndex++;
                        }
                    }
                    rowNum++;
                }

                break;

            case  5:
                rowNum=3;
                for (FeedBackDTO feedBackDTO : list) {
                    ++index;
                    setZhaoshangData(feedBackDTO,sheet,index+"",rowNum,style);
                    if(feedBackDTO.getTreeList()!=null&&feedBackDTO.getTreeList().size()>0){
                        List<FeedBackDTO> treeList = feedBackDTO.getTreeList();
                        int childIndex=1;
                        for (FeedBackDTO itemDto : treeList) {
                            rowNum=rowNum+1;
//                            ++index;
                            String ind= index+"-"+childIndex;
                            setZhaoshangData(itemDto,sheet,ind,rowNum,style);
                            childIndex++;
                        }
                    }
                    rowNum++;
                }


                break;
            default:
                return wb;




        }

        return  wb;

    }

    /**
     * 征迁数据
     * @param feedBackDTO
     * @param sheet
     * @param index
     * @param rowNum
     * @param style
     */
    private  void setZhengqianData(FeedBackDTO feedBackDTO,Sheet sheet ,String index,int rowNum,CellStyle style){

        Row row = sheet.getRow(rowNum);
        if(row==null)
        {
            row= sheet.createRow(rowNum);
        }
        row.setHeight((short)550);
//        System.out.println("我的顺序："+index+"__"+feedBackDTO.getProjectName());
        Cell cell0 = getCell(row,0);
        cell0.setCellValue(index);
        cell0.setCellStyle(style);


        Cell cell1 = getCell(row,1);
        style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
        cell1.setCellStyle(style);
        cell1.setCellValue(feedBackDTO.getProjectName());

        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
        Cell cell2 = getCell(row,2);
        cell2.setCellValue(feedBackDTO.getTotalJiaodi());
        cell2.setCellStyle(style);

        Cell cell3 = getCell(row,3);
        cell3.setCellValue(feedBackDTO.getTotalChaiqian());
        cell3.setCellStyle(style);

        Cell cell4 = getCell(row,4);
        cell4.setCellValue(feedBackDTO.getTotalHu());
        cell4.setCellStyle(style);

        Cell cell5 = getCell(row,5);
        cell5.setCellValue(feedBackDTO.getWeiJiaodi());
        cell5.setCellStyle(style);

        Cell cell6 = getCell(row,6);
        cell6.setCellValue(feedBackDTO.getWeiWeichaiqian());
        cell6.setCellStyle(style);

        Cell cell7 = getCell(row,7);
        cell7.setCellValue(feedBackDTO.getWeiHu());
        cell7.setCellStyle(style);

        Cell cell8 = getCell(row,8);
        cell8.setCellValue(feedBackDTO.getGongJiaodi());
        cell8.setCellStyle(style);
        Cell cell9 = getCell(row,9);
        cell9.setCellValue(feedBackDTO.getGongChaiqian());
        cell9.setCellStyle(style);
        Cell cell10 = getCell(row,10);
        cell10.setCellValue(feedBackDTO.getGongHu());
        cell10.setCellStyle(style);

        Cell cell11 = getCell(row,11);
        cell11.setCellValue(feedBackDTO.getEndDate());
        cell11.setCellStyle(style);

        Cell cell12 = getCell(row,12);
        cell12.setCellValue(feedBackDTO.getZerenDept());
        cell12.setCellStyle(style);

        Cell cell13 = getCell(row,13);
        cell13.setCellValue(feedBackDTO.getPeiheDept());
        cell13.setCellStyle(style);

        Cell cell14 = getCell(row,14);
        cell14.setCellValue(feedBackDTO.getLeaderName());
        cell14.setCellStyle(style);

        Cell cell15 = getCell(row,15);
        cell15.setCellValue(feedBackDTO.getRemarks());
        cell15.setCellStyle(style);

        Cell cell16 = getCell(row,16);
        cell16.setCellValue(feedBackDTO.getXingxiang());
        cell16.setCellStyle(style);

        Cell cell17 = getCell(row,17);
        cell17.setCellValue(UtilsTools.getRechValue(feedBackDTO.getReachoals()+""));
        cell17.setCellStyle(style);

        Cell cell18 = getCell(row,18);
        cell18.setCellValue(feedBackDTO.getBackRemark());
        cell18.setCellStyle(style);

        Cell cell19 = getCell(row,19);
        cell19.setCellValue(feedBackDTO.getCurrentMianji());
        cell19.setCellStyle(style);

        Cell cell20 = getCell(row,20);
        cell20.setCellValue(feedBackDTO.getFinishMianji());
        cell20.setCellStyle(style);

        Cell cell21 = getCell(row,21);
        cell21.setCellValue(feedBackDTO.getCurrentChaiqian());
        cell21.setCellStyle(style);

        Cell cell22 = getCell(row,22);
        cell22.setCellValue(feedBackDTO.getFinishChaiqian());
        cell22.setCellStyle(style);

        Cell cell23 = getCell(row,23);
        cell23.setCellValue(feedBackDTO.getCurrentZhengqianhu());
        cell23.setCellStyle(style);

        Cell cell24 = getCell(row,24);
        cell24.setCellValue(feedBackDTO.getFinishZhengqianhu());
        cell24.setCellStyle(style);


    }

    /**
     * 开工数据
     * @param sheet
     * @param index
     * @param rowNum
     * @param style
     */
    private  void setKaigongData(FeedBackDTO feedBackDTO,Sheet sheet,String index ,int rowNum,CellStyle style)
    {
        Row row = sheet.getRow(rowNum);
        if(row==null)
        {
            row= sheet.createRow(rowNum);
        }
        row.setHeight((short)550);
//        System.out.println("我的顺序："+index+"__"+feedBackDTO.getProjectName());
        Cell cell0 = getCell(row,0);
        cell0.setCellValue(index);
        cell0.setCellStyle(style);


        Cell cell1 = getCell(row,1);
        style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
        cell1.setCellStyle(style);
        cell1.setCellValue(feedBackDTO.getProjectName());

        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
        Cell cell2 = getCell(row,2);
        cell2.setCellValue(feedBackDTO.getNiandujihua());
        cell2.setCellStyle(style);

        Cell cell3 = getCell(row,3);
        cell3.setCellValue(feedBackDTO.getGongjianjihua());
        cell3.setCellStyle(style);

        Cell cell4 = getCell(row,4);
        cell4.setCellValue(feedBackDTO.getPlanStartDate()); //计划开工时间
        cell4.setCellStyle(style);

        Cell cell5 = getCell(row,5);
        cell5.setCellValue(feedBackDTO.getSepNode());//9yue
        cell5.setCellStyle(style);

        Cell cell6 = getCell(row,6);
        cell6.setCellValue(feedBackDTO.getOctNode());//10yue
        cell6.setCellStyle(style);

        Cell cell7 = getCell(row,7);
        cell7.setCellValue(feedBackDTO.getNovNode());//11yue
        cell7.setCellStyle(style);

        Cell cell8 = getCell(row,8);
        cell8.setCellValue(feedBackDTO.getDecNode());//12yue
        cell8.setCellStyle(style);
        Cell cell9 = getCell(row,9);
        cell9.setCellValue(feedBackDTO.getZerenDept());
        cell9.setCellStyle(style);
        Cell cell10 = getCell(row,10);
        cell10.setCellValue(feedBackDTO.getBelong());
        cell10.setCellStyle(style);

        Cell cell11 = getCell(row,11);
        cell11.setCellValue(feedBackDTO.getLeaderName());
        cell11.setCellStyle(style);

        Cell cell12 = getCell(row,12);
        cell12.setCellValue(feedBackDTO.getRemarks());
        cell12.setCellStyle(style);

        Cell cell13 = getCell(row,13);
        cell13.setCellValue(feedBackDTO.getXingxiang());
        cell13.setCellStyle(style);

        Cell cell14 = getCell(row,14);
        cell14.setCellValue(UtilsTools.getRechValue(feedBackDTO.getReachoals()+""));
        cell14.setCellStyle(style);

        Cell cell15 = getCell(row,15);
        cell15.setCellValue(feedBackDTO.getBackRemark());
        cell15.setCellStyle(style);

        Cell cell16 = getCell(row,16);
        cell16.setCellValue(feedBackDTO.getCurrentValue());
        cell16.setCellStyle(style);

        Cell cell17 = getCell(row,17);
        cell17.setCellValue(feedBackDTO.getTotalValue());
        cell17.setCellStyle(style);

        Cell cell18 = getCell(row,18);
        cell18.setCellValue(feedBackDTO.getCompletion());
        cell18.setCellStyle(style);

       /* Cell cell19 = getCell(row,19);
        cell19.setCellValue(feedBackDTO.getCurrentMianji());
        cell19.setCellStyle(style);

        Cell cell20 = getCell(row,20);
        cell20.setCellValue(feedBackDTO.getFinishMianji());
        cell20.setCellStyle(style);

        Cell cell21 = getCell(row,21);
        cell21.setCellValue(feedBackDTO.getCurrentChaiqian());
        cell21.setCellStyle(style);

        Cell cell22 = getCell(row,22);
        cell22.setCellValue(feedBackDTO.getFinishChaiqian());
        cell22.setCellStyle(style);

        Cell cell23 = getCell(row,23);
        cell23.setCellValue(feedBackDTO.getCurrentZhengqianhu());
        cell23.setCellStyle(style);

        Cell cell24 = getCell(row,24);
        cell24.setCellValue(feedBackDTO.getFinishZhengqianhu());
        cell24.setCellStyle(style);*/
    }

    /**
     * 再见数据
     * @param feedBackDTO
     * @param sheet
     * @param index
     * @param rowNum
     * @param style
     */
    private  void setZaiJianData(FeedBackDTO feedBackDTO,Sheet sheet ,String index,int rowNum,CellStyle style){


        Row row = sheet.getRow(rowNum);
        if(row==null)
        {
            row= sheet.createRow(rowNum);
        }
        row.setHeight((short)550);
//        System.out.println("我的顺序："+index+"__"+feedBackDTO.getProjectName());
        Cell cell0 = getCell(row,0);
        cell0.setCellValue(index);
        cell0.setCellStyle(style);


        Cell cell1 = getCell(row,1);
        style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
        cell1.setCellStyle(style);
        cell1.setCellValue(feedBackDTO.getProjectName());

        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
        Cell cell2 = getCell(row,2);
        cell2.setCellValue(feedBackDTO.getNianduPlan());
        cell2.setCellStyle(style);

        Cell cell3 = getCell(row,3);
        cell3.setCellValue(feedBackDTO.getGongjianPlan());
        cell3.setCellStyle(style);

        Cell cell4 = getCell(row,4);
        cell4.setCellValue(feedBackDTO.getPlanDate());
        cell4.setCellStyle(style);

        Cell cell5 = getCell(row,5);
        cell5.setCellValue(feedBackDTO.getSepNode());
        cell5.setCellStyle(style);

        Cell cell6 = getCell(row,6);
        cell6.setCellValue(feedBackDTO.getOctNode());
        cell6.setCellStyle(style);

        Cell cell7 = getCell(row,7);
        cell7.setCellValue(feedBackDTO.getNovNode());
        cell7.setCellStyle(style);

        Cell cell8 = getCell(row,8);
        cell8.setCellValue(feedBackDTO.getDecNode());
        cell8.setCellStyle(style);
        Cell cell9 = getCell(row,9);
        cell9.setCellValue(feedBackDTO.getZerenDept());
        cell9.setCellStyle(style);
        Cell cell10 = getCell(row,10);
        cell10.setCellValue(feedBackDTO.getBelong());
        cell10.setCellStyle(style);

        Cell cell11 = getCell(row,11);
        cell11.setCellValue(feedBackDTO.getLeaderName());
        cell11.setCellStyle(style);

        Cell cell12 = getCell(row,12);
        cell12.setCellValue(feedBackDTO.getRemarks());
        cell12.setCellStyle(style);

        Cell cell13 = getCell(row,13);
        cell13.setCellValue(feedBackDTO.getXingxiang());
        cell13.setCellStyle(style);

        Cell cell14 = getCell(row,14);
        cell14.setCellValue(feedBackDTO.getCurrentValue());
        cell14.setCellStyle(style);

        Cell cell15 = getCell(row,15);
        cell15.setCellValue(feedBackDTO.getTotalValue());
        cell15.setCellStyle(style);

        Cell cell16 = getCell(row,16);
        cell16.setCellValue(UtilsTools.getRechValue(feedBackDTO.getReachoals()+""));
        cell16.setCellStyle(style);

        Cell cell17 = getCell(row,17);
        cell17.setCellValue(feedBackDTO.getBackRemark());
        cell17.setCellStyle(style);

        Cell cell18 = getCell(row,18);
        cell18.setCellValue(feedBackDTO.getCompletion());
        cell18.setCellStyle(style);
/*
        Cell cell19 = getCell(row,19);
        cell19.setCellValue(feedBackDTO.getCurrentMianji());
        cell19.setCellStyle(style);

        Cell cell20 = getCell(row,20);
        cell20.setCellValue(feedBackDTO.getFinishMianji());
        cell20.setCellStyle(style);

        Cell cell21 = getCell(row,21);
        cell21.setCellValue(feedBackDTO.getCurrentChaiqian());
        cell21.setCellStyle(style);

        Cell cell22 = getCell(row,22);
        cell22.setCellValue(feedBackDTO.getFinishChaiqian());
        cell22.setCellStyle(style);

        Cell cell23 = getCell(row,23);
        cell23.setCellValue(feedBackDTO.getCurrentZhengqianhu());
        cell23.setCellStyle(style);

        Cell cell24 = getCell(row,24);
        cell24.setCellValue(feedBackDTO.getFinishZhengqianhu());
        cell24.setCellStyle(style);*/


    }

    /**
     * 竣工数据
     * @param feedBackDTO
     * @param sheet
     * @param index
     * @param rowNum
     * @param style
     */
    private  void setJungongData(FeedBackDTO feedBackDTO,Sheet sheet ,String index,int rowNum,CellStyle style){

        Row row = sheet.getRow(rowNum);
        if(row==null)
        {
            row= sheet.createRow(rowNum);
        }
        row.setHeight((short)550);
//        System.out.println("我的顺序："+index+"__"+feedBackDTO.getProjectName());
        Cell cell0 = getCell(row,0);
        cell0.setCellValue(index);
        cell0.setCellStyle(style);


        Cell cell1 = getCell(row,1);
        style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
        cell1.setCellStyle(style);
        cell1.setCellValue(feedBackDTO.getProjectName());

        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
        Cell cell2 = getCell(row,2);
        cell2.setCellValue(feedBackDTO.getNiandujihua());
        cell2.setCellStyle(style);

        Cell cell3 = getCell(row,3);
        cell3.setCellValue(feedBackDTO.getGongjianjihua());
        cell3.setCellStyle(style);

        Cell cell4 = getCell(row,4);
        cell4.setCellValue(feedBackDTO.getPlanStartDate());
        cell4.setCellStyle(style);

        Cell cell5 = getCell(row,5);
        cell5.setCellValue(feedBackDTO.getSepNode());
        cell5.setCellStyle(style);

        Cell cell6 = getCell(row,6);
        cell6.setCellValue(feedBackDTO.getOctNode());
        cell6.setCellStyle(style);

        Cell cell7 = getCell(row,7);
        cell7.setCellValue(feedBackDTO.getNovNode());
        cell7.setCellStyle(style);

        Cell cell8 = getCell(row,8);
        cell8.setCellValue(feedBackDTO.getDecNode());
        cell8.setCellStyle(style);
        Cell cell9 = getCell(row,9);
        cell9.setCellValue(feedBackDTO.getZerenDept());
        cell9.setCellStyle(style);
        Cell cell10 = getCell(row,10);
        cell10.setCellValue(feedBackDTO.getBelong());
        cell10.setCellStyle(style);

        Cell cell11 = getCell(row,11);
        cell11.setCellValue(feedBackDTO.getLeaderName());
        cell11.setCellStyle(style);

        Cell cell12 = getCell(row,12);
        cell12.setCellValue(feedBackDTO.getRemarks());
        cell12.setCellStyle(style);

        Cell cell13 = getCell(row,13);
        cell13.setCellValue(feedBackDTO.getXingxiang());
        cell13.setCellStyle(style);

        Cell cell14 = getCell(row,14);
        cell14.setCellValue(feedBackDTO.getCurrentValue());
        cell14.setCellStyle(style);

        Cell cell15 = getCell(row,15);
        cell15.setCellValue(feedBackDTO.getTotalValue());
        cell15.setCellStyle(style);

        Cell cell16 = getCell(row,16);
        cell16.setCellValue(UtilsTools.getRechValue(feedBackDTO.getReachoals()+""));
        cell16.setCellStyle(style);

        Cell cell17 = getCell(row,17);
        cell17.setCellValue(feedBackDTO.getBackRemark());
        cell17.setCellStyle(style);

        Cell cell18 = getCell(row, 18);
        cell18.setCellValue(feedBackDTO.getCompletion());
        cell18.setCellStyle(style);


    }


    /**
     * 招商数据
     * @param feedBackDTO
     * @param sheet
     * @param index
     * @param rowNum
     * @param style
     */
    private  void setZhaoshangData(FeedBackDTO feedBackDTO,Sheet sheet ,String index,int rowNum,CellStyle style){

        Row row = sheet.getRow(rowNum);
        if(row==null)
        {
            row= sheet.createRow(rowNum);
        }
        row.setHeight((short)550);
//        System.out.println("我的顺序："+index+"__"+feedBackDTO.getProjectName());
        Cell cell0 = getCell(row,0);
        cell0.setCellValue(index);
        cell0.setCellStyle(style);


        Cell cell1 = getCell(row,1);
        style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
        cell1.setCellStyle(style);
        cell1.setCellValue(feedBackDTO.getProjectName());

        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
        Cell cell2 = getCell(row,2);
        cell2.setCellValue(feedBackDTO.getInvestor());
        cell2.setCellStyle(style);

        Cell cell3 = getCell(row,3);
        cell3.setCellValue(feedBackDTO.getContents());
        cell3.setCellStyle(style);

        Cell cell4 = getCell(row,4);
        cell4.setCellValue(feedBackDTO.getInvestment());
        cell4.setCellStyle(style);

        Cell cell5 = getCell(row,5);
        cell5.setCellValue(feedBackDTO.getGongjianTarget());
        cell5.setCellStyle(style);

        Cell cell6 = getCell(row,6);
        cell6.setCellValue(feedBackDTO.getZerenDept());
        cell6.setCellStyle(style);

        Cell cell7 = getCell(row,7);
        cell7.setCellValue(feedBackDTO.getSepNode());
        cell7.setCellStyle(style);

        Cell cell8 = getCell(row,8);
        cell8.setCellValue(feedBackDTO.getOctNode());
        cell8.setCellStyle(style);
        Cell cell9 = getCell(row,9);
        cell9.setCellValue(feedBackDTO.getNovNode());
        cell9.setCellStyle(style);

        Cell cell10 = getCell(row,10);
        cell10.setCellValue(feedBackDTO.getDecNode());
        cell10.setCellStyle(style);

        Cell cell11 = getCell(row,11);
        cell11.setCellValue(feedBackDTO.getXingxiang());
        cell11.setCellStyle(style);

        Cell cell12 = getCell(row,12);
        cell12.setCellValue(UtilsTools.getRechValue(feedBackDTO.getReachoals()+""));
        cell12.setCellStyle(style);

        Cell cell13 = getCell(row,13);
        cell13.setCellValue(feedBackDTO.getBackRemark());
        cell13.setCellStyle(style);

        Cell cell14 = getCell(row,14);
        cell14.setCellValue(feedBackDTO.getCurrentValue());
        cell14.setCellStyle(style);

        Cell cell15 = getCell(row,15);
        cell15.setCellValue(feedBackDTO.getTotalValue());
        cell15.setCellStyle(style);

        Cell cell16 = getCell(row,16);
        cell16.setCellValue(feedBackDTO.getCompletion());
        cell16.setCellStyle(style);
       



    }



    /**
     * 获取单元格
     * @param row
     * @param column
     * @return
     */
    private Cell getCell(Row row,int column)
    {
        Cell cell = row.getCell(column);
        if(null ==cell)
        {
            cell=row.createCell(column);
        }

        return cell;
    }


}
